#!/usr/bin/env python

from Bio import SeqIO
import PDZ_predictor

def load_data(hp, pdz):
    handle = open(hp, "rU")
    records = list(SeqIO.parse(handle, "fasta"))
    handle.close()
    
    peptides = dict()
    for i in records:
        peptides[i.id] = i.seq[-5:]
    
    handle = open(pdz, "rU")
    records = list(SeqIO.parse(handle, "fasta"))
    handle.close()
    
    pdz = dict()    
    for i in records:
        pdz[i.id] = i
    
    return peptides, pdz
    
if __name__ == '__main__':
    
    peptides, pdz = load_data("humanprot/humanprotein.fasta", "humanprot/pdz.fasta")
    #print len(peptides)
    pep_id = []
    pep_seq = []
    for pep in peptides:
        pep_id.append(pep)
        pep_seq.append(peptides[pep])
        
    for protein in pdz:
        for pep in peptides:
            #print peptides[pep]
            result = PDZ_predictor.scoring(pdz[protein], pep_seq, "pdzvalid.db")
            
            print result
            
    #print pdz
